<?php 
/**
 * 货品列表管理模型
 */
class GoodsListModel extends Model{
	public $table = 'goods_list';
	public $validate  = array(
		// array('spec[]','nonull','商品规格分类名称不能为空',2,3)
		);
	/**
	 * 添加货品
	 */
	public function add_goods_list($goods_gid){
		if (!$this->create()) return false;
        if($_POST['number'] == ''){ 
            $_POST['number'] = date('ymd') . $goods_gid . implode('',Q('post.spec'));
        }
        // p(Q('post.number'));
        $data = array(
                'combline' => implode(',',Q('post.spec')),
                'inventory' => Q('post.inventory',0,'intval'),
                'number' => Q('post.number'),
                'goods_gid' => $goods_gid
            ); 
        // p($data);die;
        $this->add($data);
        return true; 
	}

	/**
	 * 编辑货品
	 */
	public function edit_goods_list($goods_gid,$glid){
		if (!$this->create()) return false;
		$data = array(
		    'combline' => implode(',',Q('post.spec')),
		    'inventory' => Q('post.inventory',0,'intval'),
		    'goods_gid' => $goods_gid
		);
        $this->where("glid='{$glid}'")->update($data);
        return true;
	} 


}















 ?>